<template>
  <view class="container">
    <u--form
        labelPosition="left"
        :model="formData"
        ref="uForm"
        labelWidth="100"
        :labelStyle="labelStyle"
    >
      <project :formData="formData"/>
      <owner :formData="formData"/>
      <house :formData="formData"/>
      <material :formData="formData"/>
    </u--form>
	</view>
</template>

<script>
import {basePowerStationInfo} from "../constant/power-station";
import project from './project/index.vue'
import {getCustomerEntryDetail} from "../../../../api/customer";
import owner from './owner/index.vue'
import house from "./house/index.vue";
import material from "./material/index.vue";

  export default {
    name: "index",
    components: { project, owner, house, material},
		data() {
			return {
        formData: basePowerStationInfo,
        labelStyle: {'align-self': 'start', 'font-size': '14px'},
			}
		},
    onLoad(option) {
      if (option.id) {
        this.id = option.id;
        this.getDetail(this.id);
      }
    },
		methods: {
      // 获取详情
      async getDetail(id) {
        const { data } = await getCustomerEntryDetail(id);
        this.formData = data;
        // 临时处理 todo...
        let arr = this.formData.noFlyImgList || [];
        if (arr.length > 0) {
          this.formData.noFlyImgs = arr[0];
        } else {
          this.formData.noFlyImgs = '';
        }
        if (arr.length > 1) {
          this.formData.noFlyImgs1 = arr[1];
        } else {
          this.formData.noFlyImgs1 = '';
        }
      },
		}
	}
</script>

<style lang="scss" scoped></style>
